//
//  SaveSortVC.m
//  CJRailTransport
//
//  Created by Hank on 2018/1/3.
//  Copyright © 2018年 amplity. All rights reserved.
//

#import "SaveSortVC.h"
#import "SaveSortCell.h"
#import "SaveListVC.h"

@interface SaveSortVC ()
// 列表数据
@property (strong ,nonatomic)NSMutableArray *listDataArray;

@end

@implementation SaveSortVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // 设置导航栏
    [self setNavC];
    // 设置界面属性
    [self setViewAttribute];
    // 注册Cell
    [self registerCells];
    // 设置数据
    [self setData];
}

#pragma mark - 导航栏
- (void)setNavC
{
    self.title = @"保存分类";
    // 设置导航栏颜色
    BasicNavigationController *nVC = (BasicNavigationController *)self.navigationController;
    nVC.themeColor = [UIColor whiteColor];
    nVC.tintColor = [UIColor darkGrayColor];
}

// 设置界面属性
- (void)setViewAttribute
{
    self.view.backgroundColor = [UIColor whiteColor];
}

// 注册Cell
- (void)registerCells
{
    UINib *nib = [UINib nibWithNibName:[SaveSortCell reuseIdentifier] bundle:nil];
    [_myTableView registerNib:nib forCellReuseIdentifier:[SaveSortCell reuseIdentifier]];
}

// 设置数据
- (void)setData
{
    NSArray *dataArray = @[@{@"title":@"装车-西向",@"image":@"login_userName"},@{@"title":@"装车-东向",@"image":@"login_userName"},@{@"title":@"装支架",@"image":@"login_userName"},@{@"title":@"装散货",@"image":@"login_userName"},@{@"title":@"装零部件",@"image":@"login_userName"}];
    _listDataArray = [NSMutableArray arrayWithArray:dataArray];
}

#pragma mark - TableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return _listDataArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    SaveSortCell *cell = [tableView dequeueReusableCellWithIdentifier:[SaveSortCell reuseIdentifier] forIndexPath:indexPath];
    cell.indexPath = indexPath;
    [cell setData:_listDataArray[indexPath.row]];
    return cell;
}
#pragma mark - TableViewDelegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    // 跳转本地保存数据列表
    SaveListVC *saveListVC = [[SaveListVC alloc]init];
    saveListVC.dataType = indexPath.row;
    [self.navigationController pushViewController:saveListVC animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
